﻿function getUrlPortal() {    
    return $('#urlPortal').val();
}

function setAutoAyuda(nameControl,pURL,hiddenControl) {

    $(nameControl).autocomplete({
        source: function (request, response) {
            $.ajax({
                url: pURL,
                type: "POST",
                dataType: "json",
                data: { wordSearch: request.term },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { label: item.vNomTabla, value: item.vNomTabla, id: item.nIdeCompendio };
                    }))
                }
            })
        },
        minLength: 3,
        select: function (event, ui) {
            $(hiddenControl).val('');
            $(hiddenControl).val(ui.item.id);
        },
        open: function (event, ui) { $(hiddenControl).val(''); }
    });
}

function setAutoAyudaGen(nameCampo,nameId, pURL) {    
    $(nameCampo).autocomplete({
        source: function (request, response) {
            $.ajax({
                url: pURL,
                type: "POST",
                dataType: "json",
                data: { wordSearch: request.term },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { value: item.descripcion, id: item.identificador };
                    }))
                }
            })
        },
        minLength: 3,
        select: function (event, ui) {
            $(nameId).val('');
            $(nameId).val(ui.item.id);
        },
        open: function (event, ui) { $(nameId).val(''); }
    });
}